package com.lefeng.cockpit.datax.core.util;

public class PathUtil {
    /**
     * 转换Windows路径到Linux路径
     * @param path 输入路径
     * @return 转换后的路径
     */
    public static String convertPath(String path) {
        // 检查输入路径是否为空
        if (path == null || path.isEmpty()) {
            return path;
        }

        // 检查是否是Windows路径
        if (path.contains("\\")) {
            // 替换反斜杠为正斜杠
            return path.replace("\\", "/");
        }

        // 如果路径中没有反斜杠，假定它已经是Linux路径
        return path;
    }

    public static void main(String[] args) {
        // 测试路径转换
        String windowsPath = "C:\\Users\\Username\\Documents\\file.txt";
        String linuxPath = "/home/username/documents/file.txt";

        System.out.println("Converted Windows Path: " + convertPath(windowsPath));
        System.out.println("Linux Path (unchanged): " + convertPath(linuxPath));
    }
}
